<template>
  <div>
    <van-nav-bar
      title="周报"
      left-text="返回"
      left-arrow
      @click-left="onClickLeft"
    />
    <van-form @submit="onSubmit">
      <van-field
        v-model="data.workDown"
        label="本周完成工作"
        placeholder="请输入"
        :rules="[{ required: true, message: '本周完成工作' }]"
      />
      <van-field
        v-model="data.workLeft"
        label="本周未完成工作"
        placeholder="请输入"
        :rules="[{ required: true, message: '本周未完成工作' }]"
      />  <van-field
      v-model="data.nextWeekPlan"
      label="下周工作计划"
      placeholder="请输入"
      :rules="[{ required: true, message: '下周工作计划' }]"
    /> <van-field
      v-model="data.thisWeekZJ"
      label="本周工作总结"
      placeholder="请输入"
      :rules="[{ required: true, message: '本周工作总结' }]"
    /> <van-field
      v-model="data.workRemark"
      label="备注"
      placeholder="请输入"
      :rules="[{ required: true, message: '备注' }]"
    />
      <div style="margin: 16px;">
        <van-button round block type="info" native-type="submit">
          提交
        </van-button>
      </div>
    </van-form>

  </div>
</template>

<script>
  import {Toast} from "vant";
  import worksReport from "@/api/worksReport";
  export default {
    data() {
      return {
        data:{
          workDown:'',//完成内容
          workLeft: '',//未完成工作
          workRemark: '',//备注
          nextWeekPlan: '',//下周工作计划
          thisWeekZJ: '',//本周工作总结
        },
      };
    },
    created() {
    },
    methods: {
      /**
       * 提交
       */
      onSubmit(){
        console.log(this.$store.getters.userInfo)
        Toast.loading({
          message: '提交中...',
          forbidClick: true,
        });
        worksReport.saveReport({
          workReportType: 2,//汇报类型（1：日报，2：周报，3：月报）
          userId:this.$store.getters.userInfo.userId,
          deptId:this.$store.getters.userInfo.deptId,
          workDown: this.data.workDown,//完成内容
          workLeft: this.data.workLeft,//未完成工作
          nextWeekPlan: this.data.nextWeekPlan,//下周工作计划
          thisWeekZJ: this.data.thisWeekZJ,//本周工作总结
          workRemark: this.data.workRemark,//备注
        })
          .then(res => {
            // 返回数据
            Toast.success('提交成功');
            this.data.workDown = '';
            this.data.workLeft = '';
            this.data.workRemark = '';
            this.data.nextWeekPlan = '';
            this.data.thisWeekZJ = '';
          })
          .catch(err => {
            // 异常情况
          })

      },
      onClickLeft() {
        this.$router.push('/work')
      },
    }
  }
</script>

<style scoped>

</style>
